package com.spring.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.spring.sys.dao.SysMenuDao;
import com.spring.sys.dao.SysRoleMenuDao;
import com.spring.sys.po.SysMenu;
import com.spring.sys.po.SysRoleMenu;
import com.spring.sys.service.ISysMenuService;

@Service
public class SysMenuServiceImpl implements ISysMenuService {
	@Autowired
	private SysMenuDao sysMenuDao;
	@Autowired
	private SysRoleMenuDao sysRoleMenuDao;

	@Override
	public List<SysMenu> selectMenuListByRoleIdAndPid(Integer roleId, Integer pId) {
		// TODO Auto-generated method stub
		Map<String, Integer> map = new HashMap<>();
		map.put("roleId", roleId);
		map.put("pId", pId);
		return sysMenuDao.find("selectMenuListByRoleIdAndPid", map);
	}

	@Override
	public List<SysMenu> selectMenuListByPid(Integer pid) {
		// TODO Auto-generated method stub
		return sysMenuDao.find("selectMenuListByPid",pid);
	}

	@Override
	public SysRoleMenu selectRoleMenuByRoleIdAndMenuId(Integer roleId, Integer menuId) {
		// TODO Auto-generated method stub
		Map<String,Integer> map = new HashMap<>();
		map.put("roleId", roleId);
		map.put("menuId", menuId);
		return sysRoleMenuDao.get("selectRoleMenuByRoleIdAndMenuId",map);
	}

}
